#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
const int N = 1e5 + 10;
long long int a[N], f[N];
int n, q, l, r;
int main()
{
    cin >> n >> q;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++)
    {
        f[i] = f[i - 1] + a[i];
    }
    while (q--)
    {
        cin >> l >> r;
        long long int x = f[r] - f[l - 1];
        cout << x << endl;
    }
    return 0;
}